import Cesium from '../Ces/Cesium';

class WeLabelProxy {
    // Member variables
    _labelCollection;
    _visibleChanged;
    show;
    _labels;

    constructor(labelCollection) {
        this._labelCollection = labelCollection;
        this._visibleChanged = false;
        this.show = false;
        this._labels = [];
    }

    get length() {
        return this._labels.length;
    }

    get(i) {
        return this._labels[i];
    }

    add(options) {
        const label = this._labelCollection.add(options);
        label.show = false;
        this._labels.push(label);
        return label;
    }

    updateVisible(visible) {
        if (this.show === visible) {
            return;
        }
        this.show = visible;

        for (let i = 0; i < this._labels.length; i++) {
            this._labels[i].show = visible;
        }
    }

    destroy() {
        for (let i = 0; i < this._labels.length; i++) {
            this._labelCollection.remove(this._labels[i]);
        }
        return Cesium.destroyObject(this);
    }

    isDestroyed() {
        return false;
    }
}

export default WeLabelProxy;
